package com.chaosj.skill.discovery.loadbalance

import com.chaosj.skill.spi.seata.LoadLevel

/**
 * @Description:
 * @author: caoyangjie
 * @date: 2019年12月2019/12/23日 17:22
 * @Copyright: © 赢时胜
 */
@LoadLevel(name = "RandomLoadBalance")
class RandomLoadBalance extends AbstractLoadBalance{
    private final Random random = new Random()

    @Override
    <T> T doSelect(List<T> invokers) {
        int length = invokers.size()
        return invokers.get(random.nextInt(length))
    }
}
